﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BanHangCshap.Class.gkhtdl63.BLL
{
    public class QCBoSanphamBLL:DAL.QCBoSanphamDAL
    {
        public string QCBoSanPham_Taoma(string Ma_BoSanpham, DateTime xlD)
        {
            QCBoSanphamBLL xlQCBoSanphamBLL = new QCBoSanphamBLL();
            int Mili = xlD.Millisecond;
            string Ma = Ma_BoSanpham + "_"
                        + xlD.Year.ToString() //Dùng tới năm 9999 đc rồi
                        + xlD.Month.ToString("0#")
                        + xlD.Day.ToString("0#")
                        + xlD.Hour.ToString("0#")
                        + xlD.Minute.ToString("0#")
                        + xlD.Second.ToString("0#")
                        + Mili.ToString("0#");
            DataTable xlDT = xlQCBoSanphamBLL.QCBoSanpham_LayTheoMa(Ma);
            try
            {
                while (xlDT.Rows.Count > 0)
                {
                    Mili++;
                    Ma = Ma_BoSanpham + "_"
                        + xlD.Year.ToString()
                        + xlD.Month.ToString("0#")
                        + xlD.Day.ToString("0#")
                        + xlD.Hour.ToString("0#")
                        + xlD.Minute.ToString("0#")
                        + xlD.Second.ToString("0#")
                        + Mili.ToString("0#");
                    xlDT = xlQCBoSanphamBLL.QCBoSanpham_LayTheoMa(Ma);
                }
                return Ma;
            }
            catch (Exception)
            {
                return "";
            }
        }
    }
}
